import java.util.Arrays;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2025-03-05
 * Time: 15:40
 */
public class Test {
    public static void main1(String[] args) {
        int[] array = {4,2,5,1,7};
        Sort.insertSort(array);
        System.out.println(Arrays.toString(array));
    }

    public static void order(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }
    }
    public static void reverseOrder(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i] = array.length - 1;
        }
    }
    public static void randomOrder(int[] array){
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(array.length);
        }
    }
    public static void testInsertSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.insertSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时："+(endTime-startTime));
    }

    public static void testHeapSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.heapSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序耗时："+(endTime-startTime));
    }
    public static void testQuickSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时："+(endTime-startTime));
    }

    public static void main4(String[] args) {
        int[] array = new int[100000];
        reverseOrder(array);
        testInsertSort(array);

        testHeapSort(array);

        testQuickSort(array);
    }

    public static void main3(String[] args) {
        int[] array = {5,3,5,4,56,5,61,561,5};
        Sort.selectSort2(array);
        System.out.println(Arrays.toString(array));
    }
    public static void main(String[] args) {
        int[] array = {5,3,5,4,56,5,61,561,5};
        Sort.countSort(array);
        System.out.println(Arrays.toString(array));
    }
}
